package cn.dengta.webapp.user.entity.game;

import cn.dengta.webapp.base.entity.TimeBasedEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.Cmp;

/**
 * 小鸟游戏，用户记录
 *
 * @author Ready
 * @since 2022-10-26
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("dt_game_score_log")
public class GameScoreLog extends TimeBasedEntity {

	private static final long serialVersionUID = 1L;

	private static int status_init = 0;
	public static int status_end = 9;

	/** 用户id */
	Long userId;
	/** 游戏id */
	Long gameId;
	/** 游戏记录id */
	Long logId;
	/** 分值 */
	Integer score;
	/** 复活id */
	Long rebirthId;
	/** -9=已关闭；0=初始化；9=结束 */
	Integer status;

	public static final String USER_ID = "user_id";
	public static final String GAME_ID = "game_id";
	public static final String SCORE = "score";
	public static final String STATUS = "status";

	/** 是否结束 */
	public boolean isEnd() {
		return Cmp.eq(this.status, status_end);
	}

	public static GameScoreLog init(Long userId, Long gameId) {
		GameScoreLog log = new GameScoreLog();
		log.setUserId(userId);
		log.setGameId(gameId);
		return log;
	}

}
